{% extends "base.html" %}
{% load staticfiles %}

{% block title %}
图灵课程 - 参与考试
{% endblock %}

{% block style %}

{% endblock %}

{% block content %}
<div class="container" align="center" style=" width: 250px; height:400px;padding: 10px">

<h3 class="transition_appointment" style="color:#663333;
	font-weight:bold;">参与考试</h3>
			
			
<br>

<form action="" name = f1 method="POST" onsubmit="return checkForm(this)">
<ul>

<span style="width:35%; float:left;">
 选择科目：</span>
  <select name ="form" id="course_type" style="width: 64%; float:left;">
  {% for subject in subjects %} 
    <option value ="{{subject.courseid}}">{{subject.coursename}}</option> 
  {% endfor %} 
</select> 
<span class="clear"></span>
</ul>
<br>
<span id="course_done" class="course_done">
		
</span>
<br>
<input type="submit" value="开始考试" class="upload-button" onclick="exam()">
<input type="submit" value="查询排名" class="upload-button" onclick="rank()">
</form>
<br>


</div>

{% endblock %}
{% block other_script %}
<script type="text/javascript" src="/static/js/exam.js"></script>
<script language="javascript">
function exam(){
	document.f1.action="/OnlineExam/ShowQuestion/";  
}
function rank(){
	document.f1.action = "/OnlineExam/Rank/";
}
function checkForm(obj) {
       var form2 = document.getElementById("exam_type");
       var index = form2.selectedIndex;

       if (form2 == null){
       		alert("请选择考卷");
       		return false
       	}
       if (index < 0){
       		alert("请选择考卷");
       		return false
       	}
       var value = form2.options[index].value
       if (document.f1.action =="http://127.0.0.1:8000/OnlineExam/ShowQuestion/")
        	return confirm("确定开始考试吗?");
       else if (document.f1.action =="http://127.0.0.1:8000/OnlineExam/Rank/")
       		return confirm("确定查看该排名吗?");

    }
</script>
{% endblock %}
